<?php

class Weight_classes_model extends CI_Model{
	
	public function __construct(){
		parent::__construct();
	}
	
	function create(){
		$data = array(
					'title' => $this->input->post('title'),
					'value' => $this->input->post('value'),
					'unit' => $this->input->post('unit')
				);
		$this->db_front->insert('product_weight_class', $data);	
	}
	
	function getAll($page='', $limit=''){
		if(!empty($limit))
		$this->db->limit($limit,$page);
		$query = $this->db_front->get('product_weight_class');
		if($query -> num_rows() > 0){
			foreach ($query -> result() as $rows){
				$data[] = $rows;	
			}	
			return $data;
		}	
	}
	
	function update($weight_class_id){
		$data = array(
					'title' => $this->input->post('title'),
					'value' => $this->input->post('value'),
					'unit' => $this->input->post('unit')
				);
        $this->db_front->where('weight_class_id', $weight_class_id);
        $this->db_front->update('product_weight_class', $data);
	}
	
	function select($weight_class_id){
        return $this->db_front->get_where('product_weight_class', array('weight_class_id'=>$weight_class_id))->row();
    }
	
	function delete($weight_class_id){
		$this->db_front->delete('product_weight_class', array('weight_class_id'=>$weight_class_id));
	}
	
}

?>